package com.wgq.uitest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.wgq.uitest.exp6.ClientThread;

/**
 * 客户端页面
 */
public class Main52Activity extends AppCompatActivity {

    EditText et_main_content;
    Button btn_main_send;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main52);

        et_main_content = findViewById(R.id.et_main_content);
        btn_main_send = (Button) findViewById(R.id.btn_main_send);

        btn_main_send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                send();
            }
        });

        //ButterKnife.bind(this);
        new Thread(new ClientThread()).start();
    }

    //@OnClick(R.id.btn_main_send)
    void send(){
        Message msg = new Message();
        msg.what = 0x1234;
        Bundle bundle = new Bundle();
        System.out.println(et_main_content.getText().toString());
        bundle.putString("content", et_main_content.getText().toString());
        msg.setData(bundle);
        ClientThread.sendHandler.sendMessage(msg);
    }
}